/**
* Linkenstein  - Google Chrome extension for adveanced hyperlink copying.
* Copyright (C) 2013  Mykola Bespaliuk
*/

var request = request || {};

/**
 * Makes get XMLHttpRequest with given parameters and executes callback
 * for result if request was successful
 * @param parameters Object
 * @param callback
 */
request.get = function( parameters, callback ) {
    /** @var async Boolean */
    var async = parameters.async || false,
        xhr = new XMLHttpRequest();
    xhr.open( "GET", parameters.url, async );
    xhr.onreadystatechange = function() {
        if ( xhr.readyState == 4 ) {
            if( typeof xhr.responseText !== "undefined" && xhr.responseText !== '' ) {
                callback( xhr.responseText );
            }
        }
    };
    //noinspection JSCheckFunctionSignatures
    xhr.send();
};